package Service;

import Beans.Student;
import Dao.StudentMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName StudentService
 * @Description TODO
 * @Author Administrator
 * @Date 2021/7/415:52
 * @Version 1.0
 **/
@Service
public class StudentService {
    @Autowired
    StudentMapper studentMapper;
    //得到所有的学生数据并进行分页
    public  List<Student> getAll(){

        List<Student> students=studentMapper.selectAll();
        return students;

    }
    //存入一个学生
    public void insert(Student student){
        studentMapper.insertSelective(student);
    }
    //删除一个学生
    public void delete(Integer id){
        studentMapper.deleteByPrimaryKey(id);
    }
    //更新一个学生
    public void update(Student student){
        studentMapper.updateByPrimaryKeySelective(student);
    }
    //查询一个学生
    public String selectName(Integer id){
        Student student=studentMapper.selectByPrimaryKey(id);
        String name=student.getStudentName();
        return name;
    }

    //传入50个对象 用于测试
    public void add(){
        for(int i=0;i<50;i++){
            studentMapper.insert(new Student("s",1,1));
        }

    }

}
